test: add table-driven error-variant tests for all 16 TipError variants (closes #97) - #152
Open
Degentle12 wants to merge 1 commit into
Open
test: add table-driven error-variant tests for all 16 TipError variants (closes #97)#152Degentle12 wants to merge 1 commit into
Degentle12 wants to merge 1 commit into
Conversation
…ts (closes StellarTips#97) Replace scattered should_panic tests with a single 16-entry table mapping every TipError discriminant to a closure that triggers it. A single test function iterates the table, catches panics via catch_unwind, and verifies the expected error code is present. Unreachable variants (StellarTips#5 TransferFailed, StellarTips#7 NoTips) are documented and skipped with a SKIP: log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #97 — Table-driven error-variant tests for all 16
TipErrorvariants.Changes
error_test_table()— a single 16-entry table mapping everyTipErrordiscriminant (Project Initialization — ScriptChain Smart Contracts #1–feat: implement engagement rewarder contract with tests #16) to a human-readable label and a closure that triggers it.test_error_variants_table_driven— iterates the table, catches panics viastd::panic::catch_unwind, and verifies the expected error code is present.TransferFailed, Implement NFT-Based Book Ownership Contract #7NoTips) are documented in the table and skipped with aSKIP:log.Files
src/test.rs: +354 lines (table + test function +panic_messagehelper)Testing
Exercises 14/16 variants (2 unreachable variants gracefully skipped).